package com.gjy.sb2.domain.message;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-07-08 09:52:15
 */
public class DecryptedInputMessage implements HttpInputMessage {

    private final HttpHeaders headers;
    private final InputStream body;

    // 构造方法：接收解密后的数据
    public DecryptedInputMessage(String decryptedBody, HttpHeaders headers) {
        this.headers = headers;
        this.body = new ByteArrayInputStream(decryptedBody.getBytes()); // 封装解密后数据为流
    }

    @Override
    public InputStream getBody() {
        return this.body; // 可重复读取的流
    }

    @Override
    public HttpHeaders getHeaders() {
        return this.headers; // 保留原始Header
    }

}
